<script type="text/javascript" >
    stFacebookToolbox.load_tooltip();
    stFacebookToolbox.on_submitform('#settingForm');
    stFacebookToolbox.pagingCallbackFunction = function(data){
        data['pageid'] = jQuery('#pageid').val();
        data['gender'] = jQuery('#gender').val();
        data['locale'] = jQuery('#locale').val();
    };
    stFacebookToolboxcustom.sortColumn();
</script>

<div class="w100p bgl">
    <div class="w100p bgr p5b">
                <ul class="menu_right">
                      <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('page_analytics');" id="page_overview">Page Overview</a>
                    </li>
                    <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('fan_count');" id="fan_count">Fan count</a>
                    </li>
                    <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('user_activity');" id="user_activity">User activity</a>
                    </li>
                    <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('viral_spread');" id="viral_spread">Viral Spread</a>
                    </li>
                    <li class="current">
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('fan_list');" id="fan_list">Fan list</a>
                    </li>
                </ul>
                <p></p>
<h2 class="red_color" style="padding-left:15px;">Facebook page fan list
            </h2>
            <p align="center">
            Filter by page: <select id="pageid" onchange="stFacebookToolbox.loadPage('fan_list&pageid='+jQuery('#pageid').val()+'&gender='+jQuery('#gender').val()+'&locale='+jQuery('#locale').val());" >
            <option value="all">All</option>
            <?php foreach($page as $row):?>
            <option value="<?php echo $row->pageid;?>" <?php if($dpage == $row->pageid){echo 'selected="true"';}?>><?php echo $row->pagename;?></option>
            <?php endforeach;?>
            </select> by gender
            <select name="gender" id="gender" onchange="stFacebookToolbox.loadPage('fan_list&pageid='+jQuery('#pageid').val()+'&gender='+jQuery('#gender').val()+'&locale='+jQuery('#locale').val());">
						<option value="1" <?php if($dgender == 1){echo 'selected';}?>>All</option>
						<option value="2" <?php if($dgender == 2){echo 'selected';}?>>Male</option>
						<option value="3" <?php if($dgender == 3){echo 'selected';}?>>Female</option>
						<option value="4" <?php if($dgender == 4){echo 'selected';}?>>Unknow</option>
                    </select>
            by locale: <select id="locale" onchange="stFacebookToolbox.loadPage('fan_list&pageid='+jQuery('#pageid').val()+'&gender='+jQuery('#gender').val()+'&locale='+jQuery('#locale').val());">
            <option value="all">All</option>
            <?php foreach($locale as $row):
                            if($row->locale != ''):?>
                        <option value="<?php echo str_replace(" ","all",$row->locale);?>" <?php if($dlocale == $row->locale){ echo 'selected';}?>><?php echo str_replace(" ","all",$row->locale);?></option>

            <?php endif; endforeach;?>
            </select>
           
        </p>
<table class="widefat" cellspacing="0">
                <thead>
                    <tr>
                        <?php print_column_headers('stFacebookToolbox_stFacebookToolbox'); ?>
                    </tr>
                </thead>

                <tbody>
                <?php
                if (count($results) > 0) {
                    $tr_class = "";
                    $upload_data = wp_upload_dir();
                    foreach ($results as $result) {
                        $total = (intval($result->like_count)+intval($result->share_count)+intval($result->comment_count)+intval($result->click_count));
                        if( empty($tr_class) || $tr_class == "class='bg_gray2'"){
                            $tr_class = "class='bg_gray1'";
                        }else{
                            $tr_class = "class='bg_gray2'";
                        }
                        echo "<tr id='$result->uid' $tr_class >"
                        . "<td><img src='http://graph.facebook.com/" . $result->uid. "/picture' style='width: 75px;' /></td>"
                        . "<td>" . $result->firstname
                        . "<td>".$result->lastname."</td>"
                        . "<td>".$result->sex."</td>"
                        . "<td>".$result->locale."</td>"
                        . "</tr>"
                        ;
                    }
                }
                ?>
                </tbody>
            </table>
            <div class="page_d">
                <?php echo $pagination?>
                <div class="cl"></div>
            </div>
    </div>
</div>
